#include "mainwidget.h"

#include <QApplication>
#include "model/data.h"
#include "loginwidget.h"
#include "debug.h"
#include "model/datacenter.h"


FILE* output = nullptr;
void msgHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg) {
    const QByteArray& log = msg.toUtf8();
    (void)type;
    (void)context;
    fprintf(output, "%s\n", log.constData());
    //确保数据落入硬盘
    fflush(output);
}
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
#if DEPOLY
    output = fopen("./log.txt", "a");
    qInstallMessageHandler(msgHandler);

#endif
#if TEST_SKIP_LOGIN
    //MainWidget w;
    //LOG() << "HELLO";

    MainWidget * w = MainWidget::getInStance();
    w->show();  
#else
    LoginWidget* loginWidget = new LoginWidget(nullptr);
    loginWidget->show();
#endif
    // model::DataCenter* dataCenter = model::DataCenter::getInstance();
    // dataCenter->initDataFile();
    // dataCenter->saveDataFile();
#if TEST_NETWORK
    // network::NetClient netClient(nullptr);
    // netClient.ping();
    model::DataCenter* dataCenter = model::DataCenter::getInstance();
    dataCenter->ping();
#endif
    return a.exec();
}
